package com.grm.demo.xianchengchi;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FixThreadPoolDemo {
    public static void main(String[] args) {
        //创建线程池,参数是创造的线程数量
        ExecutorService pool = Executors.newFixedThreadPool(20);
        for (int i = 0; i < 20; i++) {
            int j = i;
            pool.execute(new Runnable() {
                @Override
                public void run() {
                    //执行任务
                    System.out.println(j);
                }
            });
        }
    }
}
